<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">

	</head>

	<body>

		<div class="col-lg-12" id="pubishNotice">
			<ol class="breadcrumb">
				<li><i class="fa fa-home"></i>
					<a href="index.html">Home</a>
				</li>
				<li><i class=""></i>发布公告</li>
			</ol>

			<div class="mcomment">
				<h3 class="page-header"><i class=""></i>发布公告</h3>
				<div class="form-group form-inline">
					<label for="noticeTitle">标题：</label>
					<input v-model="title" type="text" class="form-control" id="noticeTitle" placeholder="请输入公告标题" />
				</div>
				<div class="form-group form-inline">
					<label for="noticeType">类型：</label>
					<select v-model="comId" class="form-control">
						<option v-for="type in types" v-bind:value="type.comId">
							{{type.laName}}
						</option>
					</select>
				</div>
				<div class="form-group">
					<label for="noticeContent">公告内容：</label>
					<!--<script v-model="content" id="publishNotice" name="content" type="text/plain">
					</script>-->
					<!--<textarea v-model="content" class="form-control" id="publishNotice" cols="100%" rows="10">-->
																															<!---->
					<!--</textarea>-->

					<textarea id="text1" class="form-control" style="display: none">
								</textarea>
					<div id="meuen" class="toolbar">
					</div>
					<div style="padding: 5px 0; color: #ccc"></div>
					<div id="editor" class="text"> <!--可使用 min-height 实现编辑区域自动增加高度-->
						<p>请输入内容</p>
					</div>
				</div>
				<center>
					<div style="width: 50%;">
						<button @click="publish" class="btn btn-default">发布</button>
						<button class="btn btn-default">取消</button>
					</div>
				</center>
			</div>

		</div>

		<!--<script type="text/javascript">
			var ue = UE.getEditor('publishNotice');
		</script>-->
		<script>
			var url1 = 'http://donting.free.idcfengye.com';
			var pn = new Vue({
				el: '#pubishNotice',
				data: {
					title: '', //标题
					content: '', //内容

					comId: '',
					types: [],

				},
				methods: {

					publish: function() {
						var x=document.getElementById("text1");
						pn.content=x.value;
						axios.defaults.withCredentials = true;

						axios.post(url1+'/notice/add', {　

								'title': pn.title,
								'content': pn.content,
								'comId': pn.comId,


						}).then(function(response) {
							var rs = response.data;
							alert(rs.code);　　
							if(rs.code == 200) {

								alert("添加成功!");
							} else {
								alert("添加失败!");
							}

						}).catch(function(error) {　　
							alert("连接超时！");
						});

					},

				},
				mounted() {
					GetType(this);
					var E = window.wangEditor

					var editor =new E('#meuen', '#editor');
					var $text1 = $('#text1')
					editor.customConfig.withCredentials = true
					editor.customConfig.uploadFileName = 'file';
					editor.customConfig.uploadImgServer = url1+'/addEdImgUp'
					editor.customConfig.onchange = function (html) {
						// 监控变化，同步更新到 textarea
						$text1.val(html)
						console.log("更新...")
					}

					editor.create()
				}
			})
		</script>

	</body>

</html>